<?php

namespace App\Http\Services;

use App\Exceptions\ServiceException;
use App\Exceptions\ServiceExceptionConstant;
use Illuminate\Http\Request;

class UploadService extends BaseService
{

    //服务器上传
    public function upload(Request $request)
    {
        try {
            $default_disk = config('admin.upload.disk');
            $path = $request->file('file')->store("avatar");
            return config('filesystems.disks.'. $default_disk .'.url') . $path;
        } catch (\Exception $exception) {
            throw new ServiceException(ServiceExceptionConstant::getErrorData('upload_failed'));
        }
    }
}
